---
title: "Global Average Temperature Anomalies"
author: "Relative to the Jan 1951-Dec 1980 average (Data: Berkeley Earth)"
#date: "18/01/2022"
output:
flexdashboard::flex_dashboard:
source_code: embed
theme:
version: 4
primary: "black"
navbar-bg: "black"
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
```
### Climate stripes { .chart-1 }
```{r}
### Data source: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
### Warming stripes: @ Ed Hawkins https://showyourstripes.info/s/globe
library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)
combined <- read.csv("berkeley.csv")
combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)
theme_strip <- theme_minimal()+
theme(axis.text.y = element_blank(),
axis.line.y = element_blank(),
panel.grid.major = element_blank(),
axis.text.x = element_text(vjust = 3, colour = "white", size = 10),
panel.grid.minor = element_blank(),
axis.title = element_blank(),
plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.title = element_text(hjust = 0.5, colour = "white", size = 10),
legend.text = element_text(colour = "white", size = 10))
col_strip <- brewer.pal(11, "RdBu")
c <- ggplot(combined, aes(x = Year, y = 1, fill = Anomaly)) +
geom_tile(aes(text = Anomaly)) +
scale_y_continuous(expand = c(0, 0)) +
scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920,
1930, 1940, 1950, 1960, 1970, 1980, 1990,
2000, 2010, 2021)) +
scale_fill_gradientn(name = "Anomaly / deg C", colors = rev(col_strip)) +
guides(fill = guide_colorbar(barwidth = 0.5)) +
theme_strip
ggplotly(c, tooltip = "text")
```
### Climate prediction (reaching 1.5°C and 2°C at the current pace) { .chart-2 }
```{r}
### Climate prediction: https://twitter.com/jrockstrom/status/1482616870394023936
library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)
combined <- read.csv("berkeley.csv")
combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)
col_strip <- brewer.pal(11, "RdBu")
forecast <- read.csv("berkeley_f.csv")
forecast$Anomaly <- formattable(forecast$Anomaly, format = "f", digits = 2)
annotation <- data.frame(
x = c(2033, 2060),
y = c(1.6, 2.1),
label = c("1.5°C", "2°C"))
f <- ggplot() +
geom_bar(data = combined, show.legend = FALSE, aes(x = Year, y = Anomaly, fill = Anomaly, text = Anomaly), stat = "identity") +
geom_bar(data = forecast, show.legend = FALSE, aes(x = Year, y = Anomaly, text = Anomaly), fill = c("#520018", "#3d0012"), colour = "black", stat = "identity") +
geom_hline(yintercept = 0, linetype = "dotted",
color = "white", size = .5) +
geom_hline(yintercept = 1.5, linetype = "dashed",
color = "white", size = .5) +
geom_hline(yintercept = 2, linetype = "dashed",
color = "white", size = .5) +
scale_fill_gradientn(colors = rev(col_strip)) +
scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920,
1930, 1940, 1950, 1960, 1970, 1980, 1990,
2000, 2010, 2021, 2033, 2060)) +
scale_y_continuous(breaks = c(0, 1.5, 2)) +
geom_text(data = annotation, aes(x = x, y = y, label = label),
color = "white",
size = 4, fontface = "bold" ) +
ylab("Anomaly / deg C") +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
ggplotly(f, tooltip = "text")
```